package main.java.com.action;

import main.java.com.domain.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * !!! Anti-fake label !!!
 * ClassName: ShellPageAction
 * Package: main.java.com.action
 * Description:
 *
 * @Author 22软件6班 陈彬
 * @Create 2023/11/27 20:51
 * @Version 1.0
 **/

@WebServlet("/ShellPageServlet")
public class ShellPageAction extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //配置请求和响应的字符集为UTF-8
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        //创建一个登录的LoginAction对象
        LoginAction lg=new LoginAction();
        String loginId=request.getSession().getAttribute("loginId").toString();
        User user=lg.queryUserInfoByLoginId(loginId);
        //将用户名写入到Session
        request.getSession().setAttribute("userName",user.getUserName());
        //将JavaBean实体类写入到session
        request.getSession().setAttribute("user",user);
        //将个人中心菜单写入到Session
        request.getSession().setAttribute("menuUrl","person.jsp");
        //getRequestDispatchar获取转发对象
        request.getRequestDispatcher("/WEB-INF/jsp/shellPage.jsp").forward(request,response);
    }
}
